home *** CD-ROM | disk | FTP | other *** search
/ Programming Microsoft Visual Basic .NET / Programming Microsoft Visual Basic .NET (Microsoft Press)(X08-78517)(2002).bin / 16 windows forms / windowsformsdemo / mdiform.vb < prev    next >
Encoding:
Text File  |  2002-03-16  |  6.7 KB  |  183 lines

  1. Public Class MDIForm
  2.     Inherits System.Windows.Forms.Form
  3.  
  4. #Region " Windows Form Designer generated code "
  5.  
  6.     Public Sub New()
  7.         MyBase.New()
  8.  
  9.         'This call is required by the Windows Form Designer.
  10.         InitializeComponent()
  11.  
  12.         'Add any initialization after the InitializeComponent() call
  13.  
  14.     End Sub
  15.  
  16.     'Form overrides dispose to clean up the component list.
  17.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  18.         If disposing Then
  19.             If Not (components Is Nothing) Then
  20.                 components.Dispose()
  21.             End If
  22.         End If
  23.         MyBase.Dispose(disposing)
  24.     End Sub
  25.     Friend WithEvents Button1 As System.Windows.Forms.Button
  26.     Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
  27.     Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
  28.     Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem
  29.     Friend WithEvents mnuNewWindow As System.Windows.Forms.MenuItem
  30.     Friend WithEvents mnuWindowCloseAll As System.Windows.Forms.MenuItem
  31.     Friend WithEvents mnuWindowArrange As System.Windows.Forms.MenuItem
  32.     Friend WithEvents mnuWindowTileVer As System.Windows.Forms.MenuItem
  33.     Friend WithEvents mnuWindowTileHor As System.Windows.Forms.MenuItem
  34.     Friend WithEvents mnuWindowCascade As System.Windows.Forms.MenuItem
  35.  
  36.     'Required by the Windows Form Designer
  37.     Private components As System.ComponentModel.Container
  38.  
  39.     'NOTE: The following procedure is required by the Windows Form Designer
  40.     'It can be modified using the Windows Form Designer.  
  41.     'Do not modify it using the code editor.
  42.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  43.         Me.mnuWindowTileVer = New System.Windows.Forms.MenuItem()
  44.         Me.mnuWindowCascade = New System.Windows.Forms.MenuItem()
  45.         Me.mnuWindowTileHor = New System.Windows.Forms.MenuItem()
  46.         Me.MainMenu1 = New System.Windows.Forms.MainMenu()
  47.         Me.MenuItem4 = New System.Windows.Forms.MenuItem()
  48.         Me.mnuNewWindow = New System.Windows.Forms.MenuItem()
  49.         Me.MenuItem1 = New System.Windows.Forms.MenuItem()
  50.         Me.mnuWindowArrange = New System.Windows.Forms.MenuItem()
  51.         Me.mnuWindowCloseAll = New System.Windows.Forms.MenuItem()
  52.         Me.Button1 = New System.Windows.Forms.Button()
  53.         Me.SuspendLayout()
  54.         '
  55.         'mnuWindowTileVer
  56.         '
  57.         Me.mnuWindowTileVer.Index = 2
  58.         Me.mnuWindowTileVer.Text = "Tile &Vertically"
  59.         '
  60.         'mnuWindowCascade
  61.         '
  62.         Me.mnuWindowCascade.Index = 0
  63.         Me.mnuWindowCascade.Text = "&Cascade"
  64.         '
  65.         'mnuWindowTileHor
  66.         '
  67.         Me.mnuWindowTileHor.Index = 1
  68.         Me.mnuWindowTileHor.Text = "Tile &Horizontally"
  69.         '
  70.         'MainMenu1
  71.         '
  72.         Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem4, Me.MenuItem1})
  73.         '
  74.         'MenuItem4
  75.         '
  76.         Me.MenuItem4.Index = 0
  77.         Me.MenuItem4.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuNewWindow})
  78.         Me.MenuItem4.MergeType = System.Windows.Forms.MenuMerge.MergeItems
  79.         Me.MenuItem4.Text = "&File"
  80.         '
  81.         'mnuNewWindow
  82.         '
  83.         Me.mnuNewWindow.Index = 0
  84.         Me.mnuNewWindow.Text = "&New Window"
  85.         '
  86.         'MenuItem1
  87.         '
  88.         Me.MenuItem1.Index = 1
  89.         Me.MenuItem1.MdiList = True
  90.         Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuWindowCascade, Me.mnuWindowTileHor, Me.mnuWindowTileVer, Me.mnuWindowArrange, Me.mnuWindowCloseAll})
  91.         Me.MenuItem1.MergeOrder = 3
  92.         Me.MenuItem1.Text = "&Window"
  93.         '
  94.         'mnuWindowArrange
  95.         '
  96.         Me.mnuWindowArrange.Index = 3
  97.         Me.mnuWindowArrange.Text = "&Arrange icons"
  98.         '
  99.         'mnuWindowCloseAll
  100.         '
  101.         Me.mnuWindowCloseAll.Index = 4
  102.         Me.mnuWindowCloseAll.Text = "C&lose All"
  103.         '
  104.         'Button1
  105.         '
  106.         Me.Button1.Location = New System.Drawing.Point(40, 48)
  107.         Me.Button1.Name = "Button1"
  108.         Me.Button1.Size = New System.Drawing.Size(208, 32)
  109.         Me.Button1.TabIndex = 0
  110.         Me.Button1.Text = "Make MDI form"
  111.         '
  112.         'MDIForm
  113.         '
  114.         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
  115.         Me.ClientSize = New System.Drawing.Size(552, 285)
  116.         Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1})
  117.         Me.Menu = Me.MainMenu1
  118.         Me.Name = "MDIForm"
  119.         Me.Text = "MDIForm"
  120.         Me.ResumeLayout(False)
  121.  
  122.     End Sub
  123.  
  124. #End Region
  125.  
  126.     ' make this form an MDI form when the button is clicked 
  127.  
  128.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  129.         ' make this form an MDI form
  130.         Me.IsMdiContainer = True
  131.         ' remove this button from the controls collection
  132.         Me.Controls.Remove(Button1)
  133.     End Sub
  134.  
  135.     ' create and display a child form
  136.  
  137.     Private Sub mnuNewWindow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuNewWindow.Click
  138.         ' display the MenuForm as a child of this form
  139.         Dim frm As New MenuForm()
  140.         frm.MdiParent = Me
  141.         frm.Show()
  142.     End Sub
  143.  
  144.     ' Change the title of the MDI parent form to match the caption
  145.     ' of the active child form.
  146.  
  147.     Private Sub MDIForm_MdiChildActivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.MdiChildActivate
  148.         If Me.ActiveMdiChild Is Nothing Then
  149.             Me.Text = "MDI Demo Program"
  150.         Else
  151.             Me.Text = Me.ActiveMdiChild.Text & " - MDI Demo Program"
  152.         End If
  153.     End Sub
  154.  
  155.     ' cascade, tile, and arrange all child forms 
  156.  
  157.     Private Sub mnuWindowCascade_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuWindowCascade.Click
  158.         Me.LayoutMdi(MdiLayout.Cascade)
  159.     End Sub
  160.  
  161.     Private Sub mnuWindowTileHor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuWindowTileHor.Click
  162.         Me.LayoutMdi(MdiLayout.TileHorizontal)
  163.     End Sub
  164.  
  165.     Private Sub mnuWindowTileVer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuWindowTileVer.Click
  166.         Me.LayoutMdi(MdiLayout.TileVertical)
  167.     End Sub
  168.  
  169.     Private Sub mnuWindowArrange_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuWindowArrange.Click
  170.         Me.LayoutMdi(MdiLayout.ArrangeIcons)
  171.     End Sub
  172.  
  173.     ' close all child forms 
  174.  
  175.     Private Sub mnuWindowCloseAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuWindowCloseAll.Click
  176.         Dim frm As Form
  177.         For Each frm In Me.MdiChildren
  178.             frm.Close()
  179.         Next
  180.     End Sub
  181.  
  182. End Class
  183.